package com.gimi.cloud.jimi.manage.controller.sys;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gimi.cloud.jimi.common.enums.ResponseCodeEnum;
import com.gimi.cloud.jimi.common.utils.JsonUtil;
import com.gimi.cloud.jimi.common.utils.reqhead.Response;
import com.gimi.cloud.jimi.common.utils.reqhead.Util;
import com.gimi.cloud.jimi.dto.sys.SysConfigDTO;
import com.gimi.cloud.jimi.entity.sys.SysConfigEntity;
import com.gimi.cloud.jimi.manage.service.sys.ConfigService;
import com.github.pagehelper.PageInfo;

/**
 * 
 * @author chendi
 *	系统配置
 */
@RestController
@RequestMapping(value = "config")
public class ConfigController {
	@Autowired
	private ConfigService configService;
	
	@RequestMapping(value = "/list")
    public void configList(@RequestBody SysConfigDTO configDTO, HttpServletResponse response) {
        Response resp = new Response();
        List<SysConfigDTO> list = configService.getConfigList(configDTO);
        resp.setRes_data(list);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
    }
	@RequestMapping(value = "/pageList")
	public void configPageList(@RequestBody SysConfigDTO configDTO, HttpServletResponse response) {
		Response resp = new Response();
		PageInfo<SysConfigEntity> list = configService.getConfigPageList(configDTO);
		resp.setRes_data(list);
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
		Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
	}
	@RequestMapping(value = "/add")
	public void configAdd(@RequestBody SysConfigDTO configDTO, HttpServletResponse response) {
		Response resp = new Response();
		configService.addConfig(configDTO);
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
		Util.sendResponse(JsonUtil.toJson(resp), response);
	}
	@RequestMapping(value = "/single")
	public void getConfigSingle(@RequestBody SysConfigDTO configDTO, HttpServletResponse response) {
		Response resp = new Response();
		SysConfigDTO configDTOSingle = configService.getConfigSingle(configDTO);
		resp.setRes_data(configDTOSingle);
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
		Util.sendResponse(JsonUtil.toJson(resp), response);
	}
	@RequestMapping(value = "/update")
	public void configUpdate(@RequestBody SysConfigDTO configDTO, HttpServletResponse response) {
		Response resp = new Response();
		configService.configUpdate(configDTO);
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
		Util.sendResponse(JsonUtil.toJson(resp), response);
	}
	@RequestMapping(value = "/delete")
	public void configDelete(@RequestBody SysConfigDTO configDTO, HttpServletResponse response) {
		Response resp = new Response();
		configService.configDelete(configDTO);
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
		Util.sendResponse(JsonUtil.toJson(resp), response);
	}
	

}
